<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<html>
<head>
<jsp:include page="../common/head.jsp" />
<style type="text/css">
/*checkbox 靠前显示*/
.permission-list > dd > dl > dd{margin-left: 0px;}
</style>
<title>编辑票据</title>
</head>
<body id="ticket-edit">
	<article class="page-container">
		<form action="ticket/save.do" method="post" class="form form-horizontal" id="ticket-form">
			<input type="hidden" value="${ticket.id}" name="id">
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>票据名：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="text" class="input-text" value="${ticket.name}" placeholder="" id="name" name="name" required="true" maxlength="30">
				</div>
			</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">排序码：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<input type="text" class="input-text" value="${ticket.sort}" placeholder="" id="sort" name="sort" number="true" maxlength="9">
				</div>
			</div>
			<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">票据属性分配：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<dl class="permission-list">
					<dd>
						<dl class="cl permission-list2">
							<dd>
								<label class=" col-sm-4 skin-minimal check-box">
									<input type="checkbox" value="1" name="type" >
									出票日期</label>
								<label class=" col-sm-4 skin-minimal check-box">
									<input type="checkbox" value="2" name="type" >
									付款人名称</label>
								<label class=" col-sm-4 skin-minimal check-box">
									<input type="checkbox" value="3" name="type" >
									收款人</label>
								<label class=" col-sm-4 skin-minimal check-box">
									<input type="checkbox" value="4" name="type" >
									出票人账号</label>
								<label class=" col-sm-4 skin-minimal check-box">
									<input type="checkbox" value="5" name="type" >
									金额</label>
								<label class=" col-sm-4 skin-minimal check-box">
									<input type="checkbox" value="6" name="type" >
									行号</label>
								<label class=" col-sm-4 skin-minimal check-box">
									<input type="checkbox" value="7" name="type" >
									出票人签章（财务）</label>
								<label class=" col-sm-4 skin-minimal check-box">
									<input type="checkbox" value="8" name="type" >
									出票人签章（人名）</label>
								<label class=" col-sm-4 skin-minimal check-box">
									<input type="checkbox" value="9" name="type" >
									记帐</label>
								<label class=" col-sm-4 skin-minimal check-box">
									<input type="checkbox" value="10" name="type" >
									对方科目（贷）</label>
								<label class=" col-sm-4 skin-minimal check-box">
									<input type="checkbox" value="11" name="type" >
									附加信息（存根）</label>
								<label class=" col-sm-4 skin-minimal check-box">
									<input type="checkbox" value="12" name="type" >
									单位主管</label>
								<label class=" col-sm-4 skin-minimal check-box">
									<input type="checkbox" value="13" name="type" >
									支票类别（委托收款还是同意转让）</label>
								<label class=" col-sm-4 skin-minimal check-box">
									<input type="checkbox" value="14" name="type" >
									开户行</label>
								<label class=" col-sm-4 skin-minimal check-box">
									<input type="checkbox" value="15" name="type" >
									开户行号</label>
								<label class=" col-sm-4 skin-minimal check-box">
									<input type="checkbox" value="16" name="type" >
									委托日期</label>
								<label class=" col-sm-4 skin-minimal check-box">
									<input type="checkbox" value="17" name="type" >
									汇款方式</label>
								<label class=" col-sm-4 skin-minimal check-box">
									<input type="checkbox" value="18" name="type" >
									汇款人全称</label>
								<label class=" col-sm-4 skin-minimal check-box">
									<input type="checkbox" value="19" name="type" >
									汇款人账号</label>
								<label class=" col-sm-4 skin-minimal check-box">
									<input type="checkbox" value="20" name="type" >
									汇出地址</label>
								<label class=" col-sm-4 skin-minimal check-box">
									<input type="checkbox" value="21" name="type" >
									汇出行名称</label>
								<label class=" col-sm-4 skin-minimal check-box">
									<input type="checkbox" value="22" name="type" >
									收款人全称</label>
								<label class=" col-sm-4 skin-minimal check-box">
									<input type="checkbox" value="23" name="type" >
									收款人账号</label>
								<label class=" col-sm-4 skin-minimal check-box">
									<input type="checkbox" value="24" name="type" >
									汇入地址</label>
								<label class=" col-sm-4 skin-minimal check-box">
									<input type="checkbox" value="25" name="type" >
									汇入行名称</label>
								<label class=" col-sm-4 skin-minimal check-box">
									<input type="checkbox" value="26" name="type" >
									支付密码</label>
								<label class=" col-sm-4 skin-minimal check-box">
									<input type="checkbox" value="27" name="type" >
									附加信息及用途</label>
								<label class=" col-sm-4 skin-minimal check-box">
									<input type="checkbox" value="28" name="type" >
									汇出行签章</label>
								<label class=" col-sm-4 skin-minimal check-box">
									<input type="checkbox" value="29" name="type" >
									复核</label>
								<label class=" col-sm-4 skin-minimal check-box">
									<input type="checkbox" value="30" name="type" >
									出票人全称</label>
								<label class=" col-sm-4 skin-minimal check-box">
									<input type="checkbox" value="31" name="type" >
									出票人账号</label>
								<label class=" col-sm-4 skin-minimal check-box">
									<input type="checkbox" value="32" name="type" >
									出票人开户行</label>
								<label class=" col-sm-4 skin-minimal check-box">
									<input type="checkbox" value="33" name="type" >
									票据张数</label>
								<label class=" col-sm-4 skin-minimal check-box">
									<input type="checkbox" value="34" name="type" >
									票据号码</label>
								<label class=" col-sm-4 skin-minimal check-box">
									<input type="checkbox" value="35" name="type" >
									会计</label>
							</dd>
						</dl>
					</dd>
				</dl>
			</div>
		</div>
			<div class="row cl">
				<label class="form-label col-xs-4 col-sm-3">备注：</label>
				<div class="formControls col-xs-8 col-sm-9">
					<textarea name="remark" cols="" rows="" class="textarea" placeholder="说点什么..." onKeyUp="$.Huitextarealength(this,50)">${ticket.remark}</textarea>
					<p class="textarea-numberbar">
						<em class="textarea-length">0</em>/50
					</p>
				</div>
			</div>
			<div class="row cl">
				<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
					<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
				</div>
			</div>
		</form>
	</article>


</body>
<jsp:include page="../common/script.jsp" />
<script type="text/javascript">
	var $dom = $("#ticket-edit");
	var $form = $dom.find("#ticket-form");
	var ticketId = "${ticket.id}";
	var checkeds = "${ticket.type}";
	$(function() {
		

		/**回显checkbox*/
		var checkArray =checkeds.split(",");
		var checkBoxAll = $dom.find("input[name='type']");
		for(var i=0;i<checkArray.length;i++){
		    //获取所有复选框对象的value属性，然后，用checkArray[i]和他们匹配，如果有，则说明他应被选中
		    $.each(checkBoxAll,function(j,checkbox){
		        //获取复选框的value属性
		        var checkValue=$(checkbox).val();
		        if(checkArray[i]==checkValue){
		            $(checkbox).attr("checked",true);
		        }
		    })
		}
		
		/**checkbox特效*/
		$('.skin-minimal input').iCheck({
			checkboxClass: 'icheckbox-blue',
			radioClass: 'iradio-blue',
			increaseArea: '20%'
		});
		
		/**校验*/
		$form.validate({
			onkeyup : false,
			focusCleanup : true,
			success : 'valid',
			submitHandler : function(form) {
				var url;
				if (C.isEmpty(ticketId)) {
					url = "ticket/add.do";
				} else {
					url = "ticket/update.do";
				}
				ajaxSubmit($form, url, function(_resp) {
					if (_resp.status == '000002') {
						U.alert(_resp.message);
						return;
					}
					U.msg('操作成功', 500, function() {
						var index = window.parent.layer.getFrameIndex(window.name);
						window.parent.load();
						window.parent.layer.close(index);
					});
				});
			}
		});
	});
</script>
</html>